package com.xiaotu.storage;

import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.common.util.SepratorUtil;
import com.xiaotu.storage.AHSetStorageProcessor;
import com.xiaotu.storage.converter.AConverter;
import com.xiaotu.storage.converter.ConverterFactory;
import com.xiaotu.storage.model.CacheDataModel;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @类名 SouShiStorageProcessor
 * @日期 2017年12月29日
 * @作者 WangYanLong
 * @功能   搜视分集概况信息存储实现类
 */
@Component("SouShiStorageProcessor")
public class SouShiStorageProcessor extends AHSetStorageProcessor
{
    public static final String[] FIELD_ARR = new String[]{"setsNo","plot","tvId"};

    private static final String[] CONVERT_ARR = new String[]{AConverter.INTEGER_CONVERT, 
    		AConverter.STRING_CONVERT,AConverter.STRING_CONVERT};
    private static final boolean[] THROW_ARR = new boolean[]{true, true, true};

    @Override
    protected String getRedisKey(Date date)
    {
        return DataRedisKeyUtils.getKey(Constants.DataRedisKey.TV_SOUSHI_YYYYMMDD, date);
    }

    @Override
    public String process(JSONObject target, CacheDataModel cacheData, Date date)
    {
    	return this.list2CSVLine(ConverterFactory.convert(target, FIELD_ARR, CONVERT_ARR, THROW_ARR));
    }

    @Override
    public String getDataType()
    {
        return Constants.PageDataType.TV_RECORD;
    }

    @Override
    public String getTaskType()
    {
        return "TV_SouShi";
    }
}
